-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use _chsize_s on Windows for truncate #24616
Conversation
Proposal to fix #24466 . Should allow files >2 GB to be truncated on Windows.
src/support/ios.c
Outdated
@@ -566,7 +566,11 @@ int ios_trunc(ios_t *s, size_t size) | |||
#if !defined(_OS_WINDOWS_) | |||
if (ftruncate(s->fd, size) == 0) | |||
#else | |||
if (_chsize(s->fd, size) == 0) | |||
#if !defined(__MINGW32__) || defined(MINGW_HAS_SECURE_API) | |||
if (_chsize_s(s->fd, size) == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should just use this function everywhere. I don't see any reason we should need the alternate code path.
Checking Windows 32bit build https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6.1-win32.exe , libgit2.dll does use `_chsize_c`, so both 32bit and 64bit should be able to use `_chsize_c`.
Alternate code path removed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
(Although we might want to wait to merge until the windows buildbot is actually running, so please don't take a delay here the wrong way.)
Should allow files >2 GB to be truncated on Windows. Fix JuliaLang#24466 Checking Windows 32bit build https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6.1-win32.exe, libgit2.dll already uses `_chsize_s`, so both 32bit and 64bit should be able to use `_chsize_s`.
Should allow files >2 GB to be truncated on Windows. Fix #24466 Checking Windows 32bit build https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6.1-win32.exe, libgit2.dll already uses `_chsize_s`, so both 32bit and 64bit should be able to use `_chsize_s`. Ref #24616 (cherry picked from commit ff045af)
Proposal to fix #24466 . Should allow files >2 GB to be truncated on Windows.